package com.ankiang.treeprint.fragment.components;

import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;

import com.ankiang.treeprint.R;
import com.ankiang.treeprint.base.BaseFragment;
import com.ankiang.treeprint.fragment.util.TRImageView;
import com.ankiang.treeprint.lib.Group;
import com.ankiang.treeprint.lib.annotation.Widget;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @author cginechen
 * @date 2017-09-13
 */

@Widget(group = Group.Home, widgetClass = TRViewImageFragment.class, iconRes = R.drawable.ic_icon_about)
public class TRViewImageFragment extends BaseFragment {

    @BindView(R.id.topbar)
    QMUITopBarLayout mTopBar;

    @BindView(R.id.imageView)
    TRImageView imageView;

    @Override
    protected View onCreateView() {
        View root = LayoutInflater.from(getActivity()).inflate(R.layout.tr_fragment_view_image, null);
        ButterKnife.bind(this, root);

        initTopBar();

        return root;
    }
    public void setDrawable(Drawable x){
        if(imageView != null) {
            this.imageView.setDrawable(x);
        }
    }

    private void initTopBar() {
        mTopBar.addLeftBackImageButton().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popBackStack();
            }
        });

        mTopBar.setTitle(getResources().getString(R.string.about_title));
    }

    @Override
    public TransitionConfig onFetchTransitionConfig() {
        return SCALE_TRANSITION_CONFIG;
    }
}
